﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Resources;
using System.Globalization;
using System.Reflection;

namespace Microsoft.Services.MSBuild.Tasks
{
    internal static class AssemblyResources
    {
        private static readonly ResourceManager resources = new ResourceManager("Microsoft.Services.MSBuild.Tasks.Strings", Assembly.GetExecutingAssembly());
        private static readonly ResourceManager sharedResources = new ResourceManager("Microsoft.Services.MSBuild.Tasks.Strings.shared", Assembly.GetExecutingAssembly());

        internal static string GetString(string name)
        {
            string str = resources.GetString(name, CultureInfo.CurrentUICulture);

            if (str == null)
            {
                str = sharedResources.GetString(name, CultureInfo.CurrentUICulture);
            }

            if (string.IsNullOrEmpty(str))
            {
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Missing resource '{0}'", name));
            }
            
            return str;
        }

        internal static ResourceManager PrimaryResources
        {
            get { return resources; }
        }

        internal static ResourceManager SharedResources
        {
            get { return sharedResources; }
        }
    }

 

}
